package com.zrrd.mcl.task.scheduled;

import com.zrrd.mcl.rabbit.constant.MqConstant;
import com.zrrd.mcl.rabbit.service.RabbitService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

@Component
@EnableScheduling
public class ScheduledTask {

    @Autowired
    private RabbitService rabbitService;

    @Scheduled(cron = "*/10 * * * * ?")
    public void sendMsg() {
        System.out.println("执行定时任务发送MQ消息=====>");
        rabbitService.sendMessage(MqConstant.EXCHANGE_DIRECT_TASK, MqConstant.ROUTING_TASK_1,"");
    }

    //每天18点执行
    @Scheduled(cron = "*/10 * * * * ?")
    public void task18(){
        System.out.println("执行定时任务发送MQ消息===清理缓存===>");
        rabbitService.sendMessage(MqConstant.EXCHANGE_DIRECT_TASK,MqConstant.ROUTING_TASK_18,"");
    }

}
